package pms.userkanri.action;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import pms.common.utils.PMSLog;
import pms.common.value.UserDataValue;
import pms.common.value.UserSessionValue;
import pms.common.utils.Consts;
import pms.userkanri.service.UserkanriService;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author Maniac
 *
 */


public class UserMainInitAction extends ActionSupport {
	
	private static final long serialVersionUID = 2276244650030984325L;
	
	private UserSessionValue userSessionValue;
	
	public UserSessionValue getUserSessionValue() {
		return userSessionValue;
	}

	public void setUserSessionValue(UserSessionValue userSessionValue) {
		this.userSessionValue = userSessionValue;
	}

	private UserkanriService userkanriService;

	private List userdatalist = new ArrayList();	

	public List getUserdatalist() {
		return userdatalist;
	}

	public void setUserdatalist(List userdatalist) {
		this.userdatalist = userdatalist;
	}

	public UserkanriService getUserkanriService() {
		return userkanriService;
	}

	public void setUserkanriService(UserkanriService userkanriService) {
		this.userkanriService = userkanriService;
	}
	private String userCount = "";
	
	public String getUserCount() {
		return userCount;
	}

	public void setUserCount(String userCount) {
		this.userCount = userCount;
	}

	private String userId = "";
	
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	private String upusername = "";	

	private String upuserdispname = "";	

	private String upuserpassword = "";	
		
	private String upuserpassword2 = "";	
		
	private String upuserkbn = "";	

	private String upkaisya = "";	

	private String upgroup = "";	

	public String getUpusername() {
		return upusername;
	}

	public void setUpusername(String upusername) {
		this.upusername = upusername;
	}

	public String getUpuserdispname() {
		return upuserdispname;
	}

	public void setUpuserdispname(String upuserdispname) {
		this.upuserdispname = upuserdispname;
	}

	public String getUpuserpassword() {
		return upuserpassword;
	}

	public void setUpuserpassword(String upuserpassword) {
		this.upuserpassword = upuserpassword;
	}

	public String getUpuserpassword2() {
		return upuserpassword2;
	}

	public void setUpuserpassword2(String upuserpassword2) {
		this.upuserpassword2 = upuserpassword2;
	}

	public String getUpuserkbn() {
		return upuserkbn;
	}

	public void setUpuserkbn(String upuserkbn) {
		this.upuserkbn = upuserkbn;
	}

	public String getUpkaisya() {
		return upkaisya;
	}

	public void setUpkaisya(String upkaisya) {
		this.upkaisya = upkaisya;
	}

	public String getUpgroup() {
		return upgroup;
	}

	public void setUpgroup(String upgroup) {
		this.upgroup = upgroup;
	}
		
	private String inusername = "";	

	private String inuserdispname = "";	

	private String inuserpassword = "";	
		
	private String inuserpassword2 = "";	
		
	private String inuserkbn = "";	

	private String inkaisya = "";	

	private String ingroup = "";	
	
	public String getInusername() {
		return inusername;
	}

	public void setInusername(String inusername) {
		this.inusername = inusername;
	}

	public String getInuserdispname() {
		return inuserdispname;
	}

	public void setInuserdispname(String inuserdispname) {
		this.inuserdispname = inuserdispname;
	}

	public String getInuserpassword() {
		return inuserpassword;
	}

	public void setInuserpassword(String inuserpassword) {
		this.inuserpassword = inuserpassword;
	}

	public String getInuserpassword2() {
		return inuserpassword2;
	}

	public void setInuserpassword2(String inuserpassword2) {
		this.inuserpassword2 = inuserpassword2;
	}

	public String getInuserkbn() {
		return inuserkbn;
	}

	public void setInuserkbn(String inuserkbn) {
		this.inuserkbn = inuserkbn;
	}

	public String getInkaisya() {
		return inkaisya;
	}

	public void setInkaisya(String inkaisya) {
		this.inkaisya = inkaisya;
	}

	public String getIngroup() {
		return ingroup;
	}

	public void setIngroup(String ingroup) {
		this.ingroup = ingroup;
	}

	@Override
	public String execute(){
		PMSLog.start();

		int userid;
		String userRights = "";		
		int userGroupId ;
		
		HttpServletRequest l_request= ServletActionContext.getRequest();		
        HttpSession l_session = l_request.getSession(true);		
		userSessionValue = (UserSessionValue)l_session.getAttribute(Consts.USER_SESSION_KEY);
        
		userid = userSessionValue.getUserId();
		userRights = userSessionValue.getUserRights();			
		userGroupId = userSessionValue.getUserGroupId();
	
        PMSLog.debug("userid:" + userid);
        PMSLog.debug("userRights:" + userRights);
        PMSLog.debug("userGroupId:" + userGroupId);
        
		userdatalist = userkanriService.select(userid,userRights,userGroupId);		
		userCount = Integer.toString(userdatalist.size());
		PMSLog.end();
		return SUCCESS;
	}
}
